# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=a2ps
pkgver=4.15.6
pkgrel=0
pkgdesc="a2ps is an Any to PostScript filter"
url="https://www.gnu.org/software/a2ps/"
# x86: segfaults all tests
# arm*: sigills in all tests
arch="all !x86 !armhf !armv7"
license="GPL-3.0-or-later"
depends="
	ghostscript
	imagemagick
	perl
	"
makedepends="
	gc-dev
	gperf
	libpaper-dev
	"
subpackages="$pkgname-doc $pkgname-emacs::noarch"
source="https://ftp.gnu.org/gnu/a2ps/a2ps-$pkgver.tar.gz
	failing-test.patch
	"

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/a2ps \
		--includedir=/usr/include \
		--disable-nls
	make
}

check() {
	make check || {
		cat tests/test-suite.log
		return 1
	}
}

package() {
	make DESTDIR="$pkgdir" install
}

emacs() {
	pkgdesc="$pkgdesc (emacs plugin)"
	install_if="$pkgname=$pkgver-r$pkgrel emacs"

	amove usr/share/emacs
}

sha512sums="
23d054a2e58c28460c5e23a1cf3f0f9c27faffc9a99781c42c11cc0693eea5bb8cfe090a97b9bae3d80cfae6b4d5b9a30dfd997a2d70be2d25988c714ad14b44  a2ps-4.15.6.tar.gz
4263f1ed74a9c3ae70c92954b8d91ca5807668be3825411902e4b9871f6d08ffb981996e7bc10f807d2e7ce82fbb4a485e304ec74d6cb25e8570b5fc0cb5c3e0  failing-test.patch
"
